import mitt from 'mitt'
import { toArray } from 'lodash-es'

const _emitter = mitt()

export const MittBusUtil: any = {}

MittBusUtil.emit = (type: string, data: any) => {
  _emitter.emit(type, data)
}

MittBusUtil.on = function() {
  // eslint-disable-next-line prefer-rest-params
  Reflect.apply(_emitter.on, _emitter, toArray(arguments))
}

MittBusUtil.unOn = function() {
  // eslint-disable-next-line prefer-rest-params
  Reflect.apply(_emitter.off, _emitter, toArray(arguments))
}


